Skip to content

fix(id/web): validate UPDATE and CURSOR frame fields in collab handleMessage (#7873) - #8648

Merged
dezren39 merged 1 commit into
mainfrom
queue/14189-7873-collab-frame-validation
Nov 11, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/14189-7873-collab-frame-validation

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

Fixes #7873 — the UPDATE and CURSOR frame family in pkgs/id/web/src/collab.ts handleMessage now validates field shapes at the boundary, in the established style of the #2824 Init hardening (and #7859/#7854):

  • UPDATE: dropped (log + return, session intact) when steps is not an array, clientIDs is not an array, or their lengths differ. All steps are then parsed with Step.fromJSON before any is applied — a parse failure is a frame shape error and drops the whole frame. Only an apply failure of well-shaped steps (inside receiveTransaction/dispatch) keeps the existing desync path (close 4001 + reconnect). Previously one malformed UPDATE (steps a string, a non-object step) threw inside the apply try and tore the session down.
  • CURSOR: dropped when clientID is not a string/number, head/anchor are not finite numbers, or name is present and not a string/null. idleSecs is used only when it is a finite number, ignored otherwise. Previously the probe frame [4, 4242, {x:1}, "abc", {evil:1}, "zzz"] was stored verbatim as a phantom cursor feeding NaN positions into the decoration/coords code.
  • CURSOR_REMOVE: clientID validated the same way before it keys the cursor map.

Tests

Five tests in the collab.test.ts harness style (describe("UPDATE/CURSOR frame validation (#7873)")), each malformed frame asserted dropped with the session intact (socket stays OPEN, no reconnect socket after timers, version unmoved), each followed by a valid-frame control that still applies/stores/removes:

Verified on the laptop: bunx vitest run src/collab.test.ts 34/34 (29 existing + 5 new); full web suite 764 passed with the single pre-existing search-panel accessibility failure that reproduces identically on clean origin/main (tracked on #8012); bunx tsc --noEmit clean.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…Message (#7873)

UPDATE: drop the frame when steps/clientIDs are not arrays of equal
length, and parse all steps with Step.fromJSON before applying any -
a parse failure is a frame shape error and drops the frame with the
session intact; only apply failures of well-shaped steps keep the
desync reconnect path. CURSOR: drop when clientID is not a
string/number, head/anchor are not finite numbers, or name is present
and not a string/null; idleSecs counts only as a finite number.
CURSOR_REMOVE: same clientID validation.

Five tests in the collab.test.ts harness style cover each malformed
frame (session intact: no close 4001, no reconnect, no phantom
cursor) with a valid-frame control after each. collab.test.ts 34/34;
tsc clean.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 10:54
@coderabbitai

coderabbitai Bot commented Nov 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 57 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3acc4eca-bef8-42c5-817e-19a015621ed3
Commits

Reviewing files that changed from the base of the PR and between b24bf9a and 8eb616f.

Files selected for processing: 2

  • pkgs/id/web/src/collab.test.ts
  • pkgs/id/web/src/collab.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T10:56:23.923785Z 8eb616f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@dezren39 dezren39 added status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state labels Nov 11, 2026
@dezren39
dezren39 merged commit cad4e14 into main Nov 11, 2026
3 of 21 checks passed
@dezren39
dezren39 deleted the queue/14189-7873-collab-frame-validation branch November 11, 2026 10:58
@dezren39 dezren39 removed status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state labels Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant